Function Reference

_GUICtrlComboInsertString

Insert a string into the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboInsertString($h_combobox, $i_index , $s_text)

 

Parameters

$h_combobox control id/control hWnd
$i_index Specifies the zero-based index of the position at which to insert the string
$s_text String to insert

 

Return Value

Success: Return the index of the position at which the string was inserted.
Failure: Returns $CB_ERR if an error occurs.
Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

 

Remarks

If the $i_index parameter is รป1, the string is added to the end of the list.

If the combo box has $WS_HSCROLL style and you insert a string wider than the
combo box, you should send a LB_SETHORIZONTALEXTENT message to ensure the
horizontal scrollbar appears

 

Related

_GUICtrlComboAddString, _GUICtrlComboDeleteString, _GUICtrlComboResetContent

 

Example


#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Insert,$Combo,$Btn_Exit,$msg,$Status,$i_index

GuiCreate("ComboBox Insert String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter String to Insert", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Insert = GuiCtrlCreateButton("Add String", 210, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("A", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"B|C|D|E|F")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Insert
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $i_index =_GUICtrlComboInsertString($Combo,_GUICtrlComboGetCurSel($Combo),GUICtrlRead($Input))
                GUICtrlSetData($Status,"String Inserted At Index: " & $i_index)
            EndIf
    EndSelect
WEnd
Exit